home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / mainedge.c < prev    next >
C/C++ Source or Header  |  1993-08-13  |  4KB  |  132 lines

  1.  
  2.  
  3.        /*********************************************
  4.        *
  5.        *       file d:\cips\mainedge.c
  6.        *
  7.        *       Functions: This file contains
  8.        *          main
  9.        *
  10.        *       Purpose:
  11.        *          This file contains the main calling
  12.        *          routine in an edge detection program.
  13.        *
  14.        *       External Calls:
  15.        *          gin.c - get_image_name
  16.        *          tiff.c - read_tiff_header
  17.        *          edge.c - quick_edge
  18.        *                   detect_edges
  19.        *          edge2.c - homogeneity
  20.        *                    range
  21.        *                    variance
  22.        *                    difference_edge
  23.        *                    contrast_edge
  24.        *          edge3.c - gaussian_edge
  25.        *                    enhance_edges
  26.        *
  27.        *       Modifications:
  28.        *          2 February 1991 - created
  29.        *          1 January 1993 - added calls to
  30.        *             range and variance functions.
  31.        *
  32.        ***********************************************/
  33.  
  34. #include "cips.h"
  35.  
  36.  
  37.  
  38. short the_image[ROWS][COLS];
  39. short out_image[ROWS][COLS];
  40.  
  41. main(argc, argv)
  42.    int argc;
  43.    char *argv[];
  44. {
  45.  
  46.    char name[80], name2[80];
  47.    int  count, i, ie, il, j, le, length, ll, size,
  48.         t, type, v, width;
  49.  
  50.  
  51.    struct   tiff_header_struct image_header;
  52.  
  53.    my_clear_text_screen();
  54.  
  55.  
  56.    if(argc < 7){
  57.     printf("\n\nNot enough parameters:");
  58.     printf("\n");
  59.     printf("\n   usage: mainedge   in-file   out-file   type ");
  60.     printf("  threshold?   threshold-value   size");
  61.     printf("\n   recall type: 1-Prewitt     2-Kirsch        3-Sobel");
  62.     printf("\n                4-quick       5-homogeneity   6-difference");
  63.     printf("\n                7-contrast    8-gaussian      9-enhance");
  64.     printf("\n                10-range      11-variance              ");
  65.     printf("\n   threshold?   1-threshold on   2-threshold off\n");
  66.     exit(0);
  67.    }
  68.  
  69.    strcpy(name, argv[1]);
  70.    strcpy(name2, argv[2]);
  71.    type = atoi(argv[3]);
  72.    t    = atoi(argv[4]);
  73.    v    = atoi(argv[5]);
  74.    size = atoi(argv[6]);
  75.  
  76.    il = 1;
  77.    ie = 1;
  78.    ll = ROWS+1;
  79.    le = COLS+1;
  80.  
  81.    read_tiff_header(name, &image_header);
  82.  
  83.    length = (ROWS-10 + image_header.image_length)/ROWS;
  84.    width  = (COLS-10 +image_header.image_width)/COLS;
  85.    count  = 1;
  86.    printf("\nlength=%d  width=%d", length, width);
  87.  
  88.    for(i=0; i<length; i++){
  89.       for(j=0; j<width; j++){
  90.         printf("\nrunning %d of %d", count, length*width);
  91.         count++;
  92.         if(type == 11)
  93.            variance(name, name2, the_image, out_image,
  94.                     il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  95.                     le+j*COLS, t, v);
  96.         if(type == 10)
  97.            range(name, name2, the_image, out_image,
  98.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  99.                       le+j*COLS, size, t, v);
  100.         if(type == 9)
  101.            enhance_edges(name, name2, the_image, out_image,
  102.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  103.                       le+j*COLS, v);
  104.         if(type == 8)
  105.            gaussian_edge(name, name2, the_image, out_image,
  106.                          il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  107.                          le+j*COLS, size, t, v);
  108.         if(type == 7)
  109.            contrast_edge(name, name2, the_image, out_image,
  110.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  111.                       le+j*COLS, t, v);
  112.         if(type == 6)
  113.            difference_edge(name, name2, the_image, out_image,
  114.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  115.                       le+j*COLS, t, v);
  116.         if(type == 5)
  117.            homogeneity(name, name2, the_image, out_image,
  118.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  119.                       le+j*COLS, t, v);
  120.         if(type == 4)
  121.            quick_edge(name, name2, the_image, out_image,
  122.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  123.                       le+j*COLS, t, v);
  124.         if(type == 3  ||  type == 2  ||  type == 1)
  125.            detect_edges(name, name2, the_image, out_image,
  126.                         il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  127.                         le+j*COLS, type, t, v);
  128.       }
  129.    }
  130.  
  131. }  /* ends main  */
  132.